<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
        <title>修改上课时段</title>
        <!-- 引入 WeUI -->
        <link rel="stylesheet" href="<?php echo base_url()?>/public/assets/css/weui.css"/>
        <link rel="stylesheet" href="<?php echo base_url()?>/public/assets/css/font-awesome.css">
        
        <style type="text/css">
            table {  
                border-collapse: collapse;     
                border: 1px solid #999;
                width: 100%;  
                text-align: center; 
                
              }    
                
              td {  
                border: 1px solid #999;  
                width: 15%;
                height: 60px;
                
              } 
                 input[type="checkbox"] {
                      -webkit-appearance: none;
                    }
                
                input[type="checkbox"] {
                    -webkit-appearance: none;
                    background-color: #fff;
                    border-radius: 100%;
                    height: 30px;
                    vertical-align: middle;
                    width: 30px; 
                    border:2px solid #999;
                    margin-top: 6px;
                    }
                input[type="checkbox"]:checked {
                    background-color:#26ca28;
                    border-color:#26ca28;
                    }
                input:focus {
                    outline:none;
                }
                @media all and (min-width: 800px) { 
                   td{line-height: 60px;} 
                   input[type="checkbox"] {
                    margin-top: -4px;
                    }
                 }
        </style>
    </head>
    <body>
        <div class="weui_media_box weui_media_text">
<!--             <h4 class="weui_media_title">修改上课时段</h4> -->
            <form action="/nursery/teacher/updatetime" method="post" onSubmit="return yanzheng()">
            <input type="hidden" value="update" name="form_submit" />
			<input type="hidden" value="<?php echo $id?>" name="teacher_id" />
            <div class="weui_media_desc">
                <table>
                <?php foreach ($type_name as $key=>$val){?>
                    <tr valign="middle"> 
                        <td rowspan="2" style="vertical-align: middle;"><?php echo $val?></td>
                        <?php for ($i=8;$i<13;$i++){?>
                        <?php $i_tmp = $i+1;?>
                        <?php 
                        $_input_time = strtotime("$i:00").'-'.strtotime("$i_tmp:00");
                        $_input_id = empty($teacher_work_time_list[$key][$_input_time]['id']) ? 0 : $teacher_work_time_list[$key][$_input_time]['id'];
                        $_input_checked = empty($teacher_work_time_list[$key][$_input_time]['status']) ? '' : 'checked';
                        ?>
                        <td><label>
                            <input type="checkbox" <?php echo $_input_checked;?> value="<?php echo "$i:00"?>-<?php echo "$i_tmp:00"?>" id="<?php echo $_input_id?>" name="<?php echo $key?>" onChange="Updatetimeajax(this)"/>
                            <br>
                            <?php echo "$i:00"?><br><?php echo "$i_tmp:00"?>
							</label>
                        </td>
                        <?php }?>
                    </tr> 
                    <tr>
                        <?php for ($i=13;$i<18;$i++){?>
                        <?php $i_tmp = $i+1;?>
                        <?php 
                        $_input_time = strtotime("$i:00").'-'.strtotime("$i_tmp:00");
                        $_input_id = empty($teacher_work_time_list[$key][$_input_time]['id']) ? 0 : $teacher_work_time_list[$key][$_input_time]['id'];
                        $_input_checked = empty($teacher_work_time_list[$key][$_input_time]['status']) ? '' : 'checked';
                        ?>
                        <td>
                        <label>
                            <input type="checkbox" <?php echo $_input_checked;?> value="<?php echo "$i:00"?>-<?php echo "$i_tmp:00"?>" id="<?php echo $_input_id?>" name="<?php echo $key?>" onChange="Updatetimeajax(this)"/>
                            <br>
                            <?php echo "$i:00"?><br><?php echo "$i_tmp:00"?>
                        </label>
                        </td>
                        <?php }?>
                    </tr>  
                  <?php }?>
                </table>
				</form>
            </div>
        </div>

    </body>
<script>
function yanzheng(){ 
	if(!$("[name='name']").val()){ 
	    alert('请输入名称！'); 
	    return false; 
	}
	var myreg = /^(((1[1-9]{1}))+\d{9})$/; 
	if(!myreg.test($("[name='mobile']").val())){ 
	    alert('请输入有效的手机号码！'); 
	    return false; 
	}
	if(!$("[name='explain']").val()){ 
	    alert('请输入简介！'); 
	    return false; 
	}
	if(!confirm('确定要修改吗？')){
		return false;
	}
}
/**
 * 修改时间
 */
function Updatetimeajax(object){
	var teacher_id = $("[name='teacher_id']").val();
	var ob_value = $(object).val();
	var ob_id = $(object).attr('id');
	var ob_checked = $(object).is(':checked');
	var work_week = $(object).attr('name');
	   $.ajax({
			 type: 'get',
			 url: '/teacher/updatetimeajax?teacher_id='+teacher_id+'&id='+ob_id+'&time_data='+ob_value+'&checked='+ob_checked+'&work_week='+work_week,
			 async : false,
			 dataType: 'json',
			 success: function (d){
				 if(d['code'] == 10){
					 $(object).attr('id',d['id']);
				}else{
					if(ob_checked){
						$(object).attr('checked',false);
					}else{
						$(object).attr('checked',true);
					}
					alert(d['msg']);
				}
			 },
		});
	//alert(ob_checked);
}
</script>
</html>
